<template>
  <div>
    <el-table
        :data="getMemberByPage"
        style="width: 100%">
        <el-table-column
          prop="accountRoleProjectId"
          label="编号"
          width="180">
        </el-table-column>
        <el-table-column
          prop="accountName"
          label="姓名"
          width="180">
        </el-table-column>
        <el-table-column
          prop="projectName"
          label="项目"
          width="180">
        </el-table-column>
        <el-table-column
          prop="roleName"
          label="角色"
          width="180">
        </el-table-column>

        <el-table-column label="操作">
          <template slot-scope="scope">
          <el-button  icon="el-icon-edit" @click="del(scope.row)" type="primary">移除</el-button>

          </template>
        </el-table-column>
        </el-table>
       <el-pagination
               fixed
               @size-change="handleSizeChange"
               @current-change="handleCurrentChange"
               :current-page="pages.current"
               :page-sizes="[1, 2, 3, 4]"
               :page-size="pages.size"
               layout="total, sizes, prev, pager, next, jumper"
               :total="pages.total">
             </el-pagination>
  </div>
</template>

<script>
  export default{
    name:"membermanagement",
    data(){
      return{
        getMemberByPage:[],
        pages:{},
        userinfo:{}
      }
    },
    methods:{
      getAllMember(current,size){
        this.$http.post("/accountRoleProject/getMemberByPage",{"current":current,
                                                        "size":size
        }).then(resp=>{
          this.getMemberByPage=resp.data.data.records

          this.pages=resp.data.data
        })
      },
      handleSizeChange(val){

        this.pages.size=val
        this.getAllMember(this.pages.num,val)
      },
      handleCurrentChange(val){
        this.pages.current=val
        this.getAllMember(val,this.pages.size)
          },
          del(user){
            this.userinfo=user
            this.$http.post("accountRoleProject/delAccount",this.userinfo).then(resp=>{
              if(resp.data.code==200){
                this.$message({
                          message: resp.data.message,
                          type: 'success'
                        })
              }else{
                this.$message.error(resp.data.message)
              }
              this.getAllMember(1,2)
            })

          }

    },
    created(){
      this.getAllMember(1,2)
    }

  }
</script>

<style>
</style>
